Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refind: account for btrfs setups when generating manual stanzas #48906

Closed
wants to merge 1 commit into from

Conversation

slymattz
Copy link
Contributor

@slymattz slymattz commented Feb 24, 2024

Testing the changes

  • I tested the changes in this PR: yes (I've been running it on x64-glibc for the past two weeks)

Local build testing

I built this PR locally for my native architecture, x86_64-glibc as well as for aarch64-glibc [EDIT: Feb 26 09:34:52 PM CET 2024].

My setup

/etc/default/refind-kernel-hook.conf

#!/bin/sh

# Change this line to 1 to update refind conf whenever new kernel is installed
UPDATE_REFIND_CONF=1

# refind.conf location
# It usually stays in
#
# /boot/EFI/refind/refind.conf
#       if you use all default configuration and EFI partition mounted to /boot
# /boot/efi/EFI/refind/refind.conf
#       if using default configuration and EFI partition mounted to /boot/efi
# /boot/EFI/BOOT/refind.conf
#       if you run refind-install --usedefault and EFI partition mounted to /boot
# /boot/efi/EFI/BOOT/refind.conf
#       likewise, EFI mounted to /boot/efi
# /efi/EFI/refind/refind.conf
# /efi/EFI/BOOT/refind.conf
REFIND_CONF=/boot/efi/EFI/refind/refind.conf

# addition kernel cmdline
OPTIONS="root=UUID=a9ee6e45-d348-4214-9560-0d0c73ab8077 ro rootflags=subvol=void/ROOT quiet loglevel=4 mem_sleep_default=deep i915.modeset=1 video=1920x1080"

/boot/efi/EFI/refind/refind.conf

timeout 5
use_nvram false
scanfor internal,optical,manual
also_scan_dirs void/ROOT/boot
dont_scan_volumes FIRE1TB-EFI,FIRE1TB-tank,KC1TB-EFI,KC2TB-EFI,KC2TB-tank,WD1TB-EFI,WD1TB-tank
resolution 1920 1080

scanfor internal works as it takes also_scan_dirs as a prefix to where to find vmlinuz and initramfs files.

However, manual stanzas generated by /etc/kernel.d/post-install/50-refind hook get me nowhere near bootable entries.

The patch that I came up with may not be perfect but it works on my installation.

Further testing is needed, especially for people with EFI mounted at /boot and using filesystems other than btrfs.

To test the changes one needs to run xbps-reconfigure -f linux6.6 or whichever kernel one's running (also make sure to adjust the settings in /etc/default/refind-kernel-hook.conf)

@slymattz
Copy link
Contributor Author

@sgn @ahesford May I ask you to please take a look at this commit. I already set my git commit email to a non-no-reply one. I would probably have to git-rebase or something.

As for the errors in compiling for aarch64, I have no idea why this package didn't compile successfully this time around as I had made no changes to the compilation phase but only to the post-install kernel hook.

Thank you in advance :)

@sgn
Copy link
Member

sgn commented Feb 25, 2024

@sgn @ahesford May I ask you to please take a look at this commit. I already set my git commit email to a non-no-reply one. I would probably have to git-rebase or something.

git commit --amend --reset-author

srcpkgs/refind/template Outdated Show resolved Hide resolved
Copy link
Member

@ahesford ahesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about rEFInd and know pretty much nothing about btrfs, but all of the magic in the hook should be dorpped in favor of simply exposing two additional variables in /etc/default/refind-kernel-hook.conf. Something like REFIND_MENU_LABEL can provide the text for the volume line and default to Void Linux, while something like REFIND_BOOT_PREFIX (or maybe some better name that I can't think of at the moment) can default to empty and be used in place of your ${rootfssubvol}${efiprefix} paths in the loader and initrd lines.

srcpkgs/refind/template Outdated Show resolved Hide resolved
@slymattz
Copy link
Contributor Author

slymattz commented Feb 25, 2024

ac296e2
I tested the following setup:

/etc/default/refind-kernel-hook.conf

#!/bin/sh

# Change this line to 1 to update refind conf whenever new kernel is installed
UPDATE_REFIND_CONF=1

# refind.conf location
# It usually stays in
#
# /boot/EFI/refind/refind.conf
#       if you use all default configuration and EFI partition mounted to /boot
# /boot/efi/EFI/refind/refind.conf
#       if using default configuration and EFI partition mounted to /boot/efi
# /boot/EFI/BOOT/refind.conf
#       if you run refind-install --usedefault and EFI partition mounted to /boot
# /boot/efi/EFI/BOOT/refind.conf
#       likewise, EFI mounted to /boot/efi
# /efi/EFI/refind/refind.conf
# /efi/EFI/BOOT/refind.conf
REFIND_CONF=/boot/efi/EFI/refind/refind.conf

# Set the label of the Void Linux filesystem
REFIND_LABEL="KC1TB-tank"

# Set the path pointing to where rEFInd should look for vmlinuz and initramfs files, e.g. /boot
REFIND_BOOT_PREFIX=void/ROOT/boot

# Additional kernel cmdline parameters
OPTIONS="root=UUID=a9ee6e45-d348-4214-9560-0d0c73ab8077 ro rootflags=subvol=void/ROOT mem_sleep_default=deep i915.modeset=1 video=1920x1080 loglevel=4"

After running xbps-reconfigure -f linux6.6 linux6.1 and rebooting, the manual boot entries boot successfully :)

@slymattz slymattz requested a review from sgn February 25, 2024 20:20
@slymattz
Copy link
Contributor Author

slymattz commented Feb 27, 2024

@sgn maintainer ping

Although initially my PR focused on btrfs setups, the simple changes proposed by @ahesford in both /etc/default/refind-kernel-hook.conf and /etc/kernel.d/post-install/50-refind are more universal as they can save a lot of trouble when installing Void manually (either through chroot from a different distribution or xchroot from Void). My argument is that these ways of installation are officially documented in Void Linux Docs (so refind could include the appropriate changes). On top of that, the part where mkfs.ext4 is listed (see https://docs.voidlinux.org/installation/guides/chroot.html#prepare-filesystems) doesn't mention the necessity to use -L "Void Linux" for painless installation of refind. Even if it did mention this detail, I believe REFIND_CONF and REFIND_BOOT_PREFIX would have to be tweaked if we were to retain the partition-and-filesystem setup proposed in Docs (see https://docs.voidlinux.org/installation/guides/chroot.html#configure-fstab).

P.S. the first workflow run failed for aarch64 (both glibc and musl) but I ran a cross-compilation of aarch64-glibc on the upstream tree yesterday and it succeeded this time so the compilation errors must've had to do with some dependency incompatibilities at the time or something. That's my guess.

What do y'all think?

Copy link
Member

@ahesford ahesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me. Please squash the commits.

@slymattz slymattz force-pushed the refind branch 2 times, most recently from 0797306 to 11c917a Compare March 6, 2024 20:27
@slymattz
Copy link
Contributor Author

slymattz commented Mar 7, 2024

As rEFInd won't cross-compile for aarch64 (both glibc and musl), I created this bug report #49170

@sgn
Copy link
Member

sgn commented Mar 9, 2024

Why do you remove the patch?

@slymattz
Copy link
Contributor Author

slymattz commented Mar 9, 2024

@sgn When you take a look at the entire thing - https://github.com/void-linux/void-packages/pull/48906/files, you'll see that the patch is not removed but it comes with your new patch. Also the name is changed from add-cross-compile-support.patch to add-cross-compile-support-and-fix-binutils-aarch64.patch to reflect the added changes. If you want me to squash any of the three commits, please let me know.

@slymattz
Copy link
Contributor Author

@ahesford @sgn is this PR mergable?

If I were to argue for the merge, I'd say that not only does it introduce sgn's patch that fixes aarch64 build, but it also makes necessary changes in the post-install kernel hook. So far, the hook has only been able to generate entries that work with EFI mounted in /boot. I'm really surprised no one ever raised this issue before.

refind-path
Source: https://wiki.archlinux.org/title/REFInd#For_manual_boot_stanzas

Given what I said before, I would even argue that the defaults could be REFIND_CONF=/boot/efi/EFI/refind/refind.conf and REFIND_BOOT_PREFIX=/boot since this is the standard approach of keeping kernels as part of the ROOTFS filesystem. Mounting the EFI part in /boot/efi (as opposed to /boot) is also recommended in the official Void docs. Although some people do store kernels on the EFI partition, I doubt whether this is a standard approach.

Looking forward to hearing from you guys :)

Copy link
Member

@ahesford ahesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make some minor adjustments and squash these commits down to one.

srcpkgs/refind/files/kernel.post-install Outdated Show resolved Hide resolved
srcpkgs/refind/files/refind-kernel-hook.conf Outdated Show resolved Hide resolved
srcpkgs/refind/files/refind-kernel-hook.conf Outdated Show resolved Hide resolved
@ahesford
Copy link
Member

I don't think you should rename the patch; its original name is sufficiently descriptive, and changing the name makes tracking changes a little more confusing.

@slymattz
Copy link
Contributor Author

I don't think you should rename the patch; its original name is sufficiently descriptive, and changing the name makes tracking changes a little more confusing.

OK, done. Is it OK now? :)

@slymattz
Copy link
Contributor Author

slymattz commented Mar 18, 2024

image

Got a lint error saying the second line should be blank. So I amended the description of the last commit and added an extra return line after subject so that git parses body as body. I believe commit 32fff16 should pass the test just fine.

@slymattz
Copy link
Contributor Author

@ahesford Hi! Can you please review my commit 32fff16 and re-run a workflow check? Thanks in advance.

While REFIND_LABEL identifies the volume on which vmlinuz and initramfs files
reside REFIND_BOOT_PREFIX prepends a path that is relative to this volume.
This commit also fixes aarch64 build problems related to binutils 2.38+
snwnde pushed a commit to snwnde/void-packages that referenced this pull request Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants